package com.cy.store.controller;

import com.cy.store.entity.Product;
import com.cy.store.service.IProductService;
import com.cy.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/product")
public class ProductController extends BaseController{
    @Autowired
    private IProductService productService;

    @RequestMapping("/list_hot")
    public JsonResult<List<Product>> listHot(){
        List<Product> data = productService.findHot();
        return new JsonResult<>(Ok,data);
    }

    @RequestMapping("{id}/details")
    public JsonResult<Product> details(@PathVariable("id") Integer id){
        Product data = productService.findById(id);
        return new JsonResult<>(Ok,data);
    }
}
